function [x, a, b_new] = SolveEquationSystemGaussCustom2( A, b)
%Gets the solution of the equation system using gaussian elimination
C = sym([A b]);
N = size(A, 1);
M = size(A, 2);
for i = 1 : N - 1
    maxIndex = MaxElementIndex(A, i);
    C = ShiftRows(C, i, maxIndex(1));
    for k = i + 1 : N
        C = SubtractRows(C, i, k);
    end
end;
system = MakeSymbolicEquationSystem(C);
result = solve(system);
result = struct2cell(result);

for i = 1 : M
    if (i > size(result, 1))
        xn = strcat('x', num2str(i));
        result(i) = cellstr(xn);
        continue;
    end;
    xn = char(result{i});
    if ~StrHasSymbols(xn)
        xn = double(result{i});
        xn = sprintf('%.4f', xn);
    end
    result(i) = cellstr(xn);
end;

x = result;
a = C(:, 1 : M);
b_new = C(:, M + 1);

end



